﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FindPwd.aspx.cs" Inherits="ProjectStudy.注册登录找回密码修改密码页面.FindPwd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#findNext").click(function () {
                var username = $.trim($("#findUsername").val());
                if (username == null || username == '') {
                    $("#findUsernameValid").html("请输入账号");
                    $("#findUsernameValid").css("display", "inherit");
                }
                else {
                    $.ajax({
                        type: "post",
                        url: "/Ajax/RegisterLoginChangePwdFindPwd.ashx",
                        data: { "action": "findpwd", "username": username, "step": "1" },
                        dataType: "json",
                        success: function (data) {
                            if (data["status"] == "hasUsername") {
                                $("#tb1").css("display", "none");
                                $("#tb2").css("display", "inherit");
                                $("#findQuestion").val(data["question"]);

                                $("#findAnswer").focus(function () {
                                    $("#findAnswerValid").css("display", "none");
                                });

                                $("#findOK").click(function () {
                                    $("#findUsernameValid").css("display", "none");
                                    var answer = $.trim($("#findAnswer").val());
                                    $.ajax({
                                        type: "post",
                                        url: "/Ajax/RegisterLoginChangePwdFindPwd.ashx",
                                        data: { "action": "findpwd", "step": "2", "answer": answer },
                                        dataType: "json",
                                        success: function (data) {
                                            if (data["status"] == "success") {
                                                if (confirm("密码找回成功，初始密码已发送至" + data["email"] + ",是否返回登陆界面？")) {
                                                    window.location.href = "Login.aspx";
                                                }
                                            }
                                            else if (data["status"] == "answerErr") {
                                                $("#findAnswerValid").html("*答案错误");
                                                $("#findAnswerValid").css("display", "inherit");
                                            }
                                        }
                                    });
                                });
                            }
                            else if (data["status"] == "noUsername") {
                                $("#findUsernameValid").css("display", "inherit");
                            }
                        }
                    });
                }
            });
        });
    </script>
    <title></title>

    <style type="text/css"> 
      html{ background-color:DeepSkyBlue;}
      .fatherDiv{width:550px;
               height:220px;
               background-color:white;
               text-align:center;
               margin:180px auto;}
    .fatherDiv span{height:100%;
                    width:0px;
                    display:inline-block;
                    vertical-align:middle;}
    .sonDiv{width:530px;
            height:200px;
            background-color:PowderBlue;
            display:inline-block;
            vertical-align:middle;}
    /* button 
    ---------------------------------------------- */ 
    .button { 
    display: inline-block; 
    zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */ 
    *display: inline; 
    vertical-align: baseline; 
    margin: 0 2px; 
    outline: none; 
    cursor: pointer; 
    text-align: center; 
    text-decoration: none; 
    font: 14px/100% Arial, Helvetica, sans-serif; 
    padding: .5em 1.5em .4em; 
    text-shadow: 0 1px 1px rgba(0,0,0,.3); 
    -webkit-border-radius: .5em; 
    -moz-border-radius: .5em; 
    border-radius: .5em; 
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2); 
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2); 
    box-shadow: 0 1px 2px rgba(0,0,0,.2); 
    } 
    .button:hover { 
    text-decoration: none; 
    } 
    .button:active { 
    position: relative; 
    top: 1px; 
    } 
    
    /* blue */ 
    .blue { 
    color: #d9eef7; 
    border: solid 1px #0076a3; 
    background: #0095cd; 
    background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5)); 
    background: -moz-linear-gradient(top, #00adee, #0078a5); 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5'); 
    } 
    .blue:hover { 
    background: #007ead; 
    background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e)); 
    background: -moz-linear-gradient(top, #0095cc, #00678e); 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e'); 
    } 
    .blue:active { 
    color: #80bed6; 
    background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee)); 
    background: -moz-linear-gradient(top, #0078a5, #00adee); 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee'); 
    } 
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style=" margin:0 auto;">
    <div class="fatherDiv">
       <span class="sonSpan"></span>
       <div class="sonDiv">
           <label style=" font-size:30px; margin-top:20px ">密码找回</label>
       <table  id="tb1" style=" margin:20px auto;">
      <tr style=" height:30px;">
        <td style=" width:140px"><label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 账号:</label></td>
        <td><input  type="text" id="findUsername" style=" height:25px; line-height:25px; font-size:16px; width:180px;"/></td>
        <td style=" width:140px"><label id="findUsernameValid" style="  color:Red; display:none;">*账号不存在</label></td>
      </tr>
      
      <tr style=" height:30px;">
        <td></td>
        <td> <input  type="button" id="findNext" value="下一步" class="button blue"/>&nbsp; <input  type="button" id="findClear" value="清除" class="button blue"/></td>
      </tr>
    </table>

    <table id="tb2" style=" margin:20px auto;display:none; ">
      <tr>
        <td style=" width:140px"><label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 问题:</label></td>
        <td><input  type="text" id="findQuestion"  readonly="readonly" style=" height:25px; line-height:25px; font-size:16px; width:180px;"/></td>
      </tr>
      <tr>
        <td><label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 答案:</label></td>
        <td><input  type="text" id="findAnswer" style=" height:25px; line-height:25px; font-size:16px; width:180px;"/></td>
        <td style=" width:140px"><label id="findAnswerValid" style="  color:Red; display:none;">*问题错误</label></td>
      </tr>
      <tr style=" height:30px;">
        <td></td>
        <td> <input  type="button" id="findOK" value="确定" class="button blue"/>&nbsp; <input  type="button" id="Button2" value="清除" class="button blue"/></td>
      </tr>
    </table>
       </div>
       <span class="sonSpan"></span>
     </div>
    
    </div>
    </form>
</body>
</html>
